<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Search extends CI_Controller {

	/**
	 * Index Page for this controller.
	 *
	 */
	public function index($string=NULL)
	{
		$data['stylesheet'] = '/theme/' ;
		$data['image_path'] = '/theme/images/' ;
		$data['keywords'] = '盘享，盘享网，网盘，云盘，互联网网盘，网盘分享' ;
		$data['description'] = '盘享网提供互联网网盘资源搜索和检索，促进资源的便捷获取和共享' ;

        $this->load->library('form_validation');
		$this->load->helper(array('form'));

		//$this->form_validation->set_rules('srchtxt', '搜索关键字', 'trim|required|xss_clean');
       //if ($this->form_validation->run() == false) {
		//}else{
			$string = (strpos($string,'-')===0)?substr($string,1):$string ;
			$url_query = explode('-',$string) ;
			$srchtxt1 = (int)!empty($url_query[0])?$url_query[0]:'' ;
			$page = (int)!empty($url_query[1])?$url_query[1]:0 ;
			$srchtxt = $this->input->post('srchtxt')?$this->input->post('srchtxt'):urldecode($srchtxt1);
			$this->load->model('mrecords');  

			$data['lists'] = $this->mrecords->search_pagination($srchtxt, $page, $data['totalcount'] ,20);
			$data['pagination'] = pagination('search/index-'.$srchtxt.'-%d',$page, $data['totalcount'],20);
			$data['hot'] = $this->mrecords->get_hot_all();  
			$data['srchtxt'] = $srchtxt ;
			$data['head_title'] = $srchtxt.'搜索-盘享网' ;

			$this->load->view('header',$data);
			$this->load->view('search_index');
			$this->load->view('footer');
		//}
	}
}